package com.controller;

import cn.hutool.extra.mail.Mail;


import com.annotation.IgnoreAuth;

import com.service.impl.MailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.security.GeneralSecurityException;

@RestController
@RequestMapping("mail")
public class testController {

    @Autowired
    private MailService mailService;

    @IgnoreAuth
    @GetMapping("/send")
    public String sendMail(@RequestParam String to,
                           @RequestParam String subject,
                           @RequestParam String content) {
        try {
            mailService.sendSimpleMail(to, subject, content);
            return "邮件发送成功！";
        } catch (Exception e) {
            e.printStackTrace();
            return "邮件发送失败：" + e.getMessage();
        }
    }


}
